
// ***********************************************************************
// AUTO GENERATED CLASS - Do Not Modify this file, if needed modify .tt
// ***********************************************************************
// Assembly         : InnovaApp_DomainLayer
// Author           : LJO+01
// Created          : 17/11/2013 20:29:50
// ***********************************************************************
// <copyright file="N.A." company="Copyright © Innovacall 2011">
//     Copyright (c) . All rights reserved.
// </copyright>
// <summary>
// Domain layer  
// DomainClass
// </summary>
// ***********************************************************************

using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;


namespace InnovaApp.Layers.DomainLayer
{
    /// <summary>
    /// Class Contact_ContactAddress_AddressType
    /// </summary>
    [Serializable]
    public partial class Contact_ContactAddress_AddressType : _DomainLayer_Base  
    {
        #region Primitive Properties
    	
        /// <summary>
        /// Gets or sets Id.
        /// </summary>
        /// <value>The Id.</value>
        public virtual int Id
        {
            get;
            set;
        }
    	
        /// <summary>
        /// Gets or sets FK_Contact_ContactAddress.
        /// </summary>
        /// <value>The FK_Contact_ContactAddress.</value>
        /// <remarks>
        /// Foregn key of Contact_ContactAddress_AddressType
        /// 
        /// </remarks>
        public virtual int FK_Contact_ContactAddress
        {
            get { return _fK_Contact_ContactAddress; }
            set
            {
                if (_fK_Contact_ContactAddress != value)
                {
                    if (Contact_ContactAddress != null && Contact_ContactAddress.Id != value)
                    {
                        Contact_ContactAddress = null;
                    }
                    _fK_Contact_ContactAddress = value;
                }
            }
        }
        private int _fK_Contact_ContactAddress;
    	
        /// <summary>
        /// Gets or sets FK_AddressType.
        /// </summary>
        /// <value>The FK_AddressType.</value>
        /// <remarks>
        /// Foregn key of Contact_ContactAddress_AddressType
        /// 
        /// </remarks>
        public virtual int FK_AddressType
        {
            get { return _fK_AddressType; }
            set
            {
                if (_fK_AddressType != value)
                {
                    if (AddressType != null && AddressType.Id != value)
                    {
                        AddressType = null;
                    }
                    _fK_AddressType = value;
                }
            }
        }
        private int _fK_AddressType;
    	
        /// <summary>
        /// Gets or sets rowversion.
        /// </summary>
        /// <value>The rowversion.</value>
        public virtual byte[] rowversion
        {
            get;
            set;
        }

        #endregion

        #region Navigation Properties
        public virtual AddressType AddressType
        {
            get { return _addressType; }
            set
            {
                if (!ReferenceEquals(_addressType, value))
                {
                    var previousValue = _addressType;
                    _addressType = value;
                    FixupAddressType(previousValue);
                }
            }
        }
        private AddressType _addressType;
        public virtual Contact_ContactAddress Contact_ContactAddress
        {
            get { return _contact_ContactAddress; }
            set
            {
                if (!ReferenceEquals(_contact_ContactAddress, value))
                {
                    var previousValue = _contact_ContactAddress;
                    _contact_ContactAddress = value;
                    FixupContact_ContactAddress(previousValue);
                }
            }
        }
        private Contact_ContactAddress _contact_ContactAddress;

        #endregion

        #region Association Fixup
    
        private void FixupAddressType(AddressType previousValue)
        {
            if (previousValue != null && previousValue.Contact_ContactAddress_AddressType.Contains(this))
            {
                previousValue.Contact_ContactAddress_AddressType.Remove(this);
            }
    
            if (AddressType != null)
            {
                if (!AddressType.Contact_ContactAddress_AddressType.Contains(this))
                {
                    AddressType.Contact_ContactAddress_AddressType.Add(this);
                }
                if (FK_AddressType != AddressType.Id)
                {
                    FK_AddressType = AddressType.Id;
                }
            }
        }
    
        private void FixupContact_ContactAddress(Contact_ContactAddress previousValue)
        {
            if (previousValue != null && previousValue.Contact_ContactAddress_AddressType.Contains(this))
            {
                previousValue.Contact_ContactAddress_AddressType.Remove(this);
            }
    
            if (Contact_ContactAddress != null)
            {
                if (!Contact_ContactAddress.Contact_ContactAddress_AddressType.Contains(this))
                {
                    Contact_ContactAddress.Contact_ContactAddress_AddressType.Add(this);
                }
                if (FK_Contact_ContactAddress != Contact_ContactAddress.Id)
                {
                    FK_Contact_ContactAddress = Contact_ContactAddress.Id;
                }
            }
        }

        #endregion

    }
}
